package org.cangku.controller;

import org.cangku.dao.ShopDao;
import org.cangku.entity.Shop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/shopcontrllo")
public class ShopController {
    @Autowired
    private ShopDao shopDao;

    @RequestMapping("/query")
    @ResponseBody
    public List<Shop> query(){
        return shopDao.queryShop();
    }

    @RequestMapping("/count")
    @ResponseBody
    public Map<String,Object> queryByKucun(int kid,int num){
        Map<String,Object> map = new HashMap<String, Object>();

        int count = shopDao.getKucunById(kid);

        if(count>=num){
            map.put("flag",true);
        }else{
            map.put("flag",false);
        }
        return map;
    }
}
